package com.woniuxy.finance.controller;

import com.woniuxy.commons.request.Message;
import com.woniuxy.commons.request.ResPage;
import com.woniuxy.commons.request.ResponseResult;
import com.woniuxy.commons.request.StateCode;
import com.woniuxy.finance.entity.Consult;
import com.woniuxy.finance.entity.Search;
import com.woniuxy.finance.entity.vo.LogsVo;
import com.woniuxy.finance.service.ConsultService;
import com.woniuxy.finance.service.LogsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/consult")
public class ConsultController {
    @Resource
    private ConsultService consultService;

    @PostMapping("/findAll/{page}/{size}")
    public ResponseResult<ResPage<List<Consult>>> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){

        return new ResponseResult<>(ResponseResult.OK, consultService.findAll(page, size));
    }
    @PostMapping("/findByCondition")
    public ResponseResult<ResPage<List<Consult>>> findByCondition(@RequestBody Search search){

        return new ResponseResult<>(ResponseResult.OK, consultService.findByCondition(search));
    
    }
    /**
     * 删除消息
     */
    @DeleteMapping("/deleterow/{id}")
    public ResponseResult<Boolean> deletePerms(@PathVariable("id") Integer id){
        return new ResponseResult<>(StateCode.SUCCESS, Message.SUCCESS,consultService.deletePerms(id));    }
    /**
     * 添加资讯
     */
    @PostMapping("/addform")
    public ResponseResult<Boolean> addform(@RequestBody Consult consult){
        return new ResponseResult<>(StateCode.SUCCESS, Message.SUCCESS,consultService.addform(consult));
    }
    @PutMapping("/editform")
    public ResponseResult<Boolean> editform(@RequestBody Consult consult){
        return new ResponseResult<>(StateCode.SUCCESS,Message.SUCCESS,consultService.editform(consult));
    }
}
